/*================================================================
 *   Copyright (C) 2014 All rights reserved.
 *
 *   文件名称：ClientConn.h
 *   创 建 者：Zhang Yuanhao
 *   邮    箱：bluefoxah@gmail.com
 *   创建日期：2014年12月30日
 *   描    述：
 *
 ================================================================*/

#ifndef CLIENTCONN_H_
#define CLIENTCONN_H_

#include "imconn.h"
#include <list>
using namespace std;

class ClientConn : public CImConn
{
public:
	ClientConn();
	virtual ~ClientConn();

	bool IsOpen() { return m_bOpen; }

    net_handle_t connect(const string& strIp, uint16_t nPort);
    
    list<uint32_t>& onlineUser() { return m_lsOnlineUsers; }
    
    virtual void Close();
public:
    void login(uint32_t nUserId);
    void getOnlineUser();
    void initCall(uint32_t nPeerId, uint32_t nCallId);
    void hangupCall(uint32_t nPeerId, uint32_t nCallId);
public:
	virtual void OnConfirm();
	virtual void OnClose();
	virtual void OnTimer(uint64_t curr_tick);

	virtual void HandlePdu(CImPdu* pPdu);
private:
    void HandleLoginRes(CImPdu* pPdu);
    void HandleOnlineUserRes(CImPdu* pPdu);
    void HandleInitCallRes(CImPdu* pPdu);
    
    void HandleCallNotify(CImPdu* pPdu);
    void HandleHungUp(CImPdu* pPdu);
private:
    bool        m_bOnCall;
	bool 		m_bOpen;
    list<uint32_t> m_lsOnlineUsers;
    
};


#endif /* CLIENTCONN_H_ */
